home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 24 / AACD 24.iso / AACD / Online / Epic4 / share / epic / help / 6_functions / indextoitem < prev    next >
Text File  |  2001-03-21  |  2KB  |  42 lines

  1. Synopsis:
  2.    $indextoitem(<array> <index number>)
  3.    $itemtoindex(<array> <item number>)
  4.  
  5. Technical:
  6.    These functions are used to convert between array item numbers are index
  7.    numbers.
  8.  
  9.    Item numbers are counted incrementally as items are added to an array,
  10.    starting at 0 (zero).  Each new item uses the next available item number;
  11.    if there are 5 items in an array, the next item that may be added is item
  12.    number 5 (remember that we count from zero... 5 items is 0..4).
  13.  
  14.    Index numbers represent each items position in the array when sorted.
  15.    Items are sorted based on their ascii values.  This is generally
  16.    alphabetical; however, since it is based on ascii values, all capital
  17.    letters are sorted after all lowercase letters.  It follows a sorting
  18.    algorithm similar to the $sort() function's.
  19.  
  20. Practical:
  21.    The $indextoitem() function converts an index number in the given array
  22.    to its corresponding item number; $itemtoindex() does just the opposite.
  23.    This is mostly useful in conjunction with $igetitem() or $ifinditem(),
  24.    allowing an array to be dealt with in a logical order.
  25.  
  26. Returns:
  27.      -2   cannot find index/item number in array
  28.      -1   cannot find named array
  29.    > -1   item number corresponding to given index number (and vice verse)
  30.  
  31. Examples:
  32.    $setitem(booya 0 hello)
  33.    $setitem(booya 1 goodbye)
  34.    $itemtoindex(booya 0)                 returns 1
  35.    $indextoitem(booya 1)                 returns 0
  36.    $itemtoindex(foobar 0)                returns -1
  37.    $itemtoindex(booya 100)               returns -2
  38.  
  39. See Also:
  40.    Arrays(7); ifinditem(6); igetitem(6); setitem(6); sort(6)
  41.  
  42.